import request from "@/utils/request";

// 获取打印管理列表
export function listPrintManagement(query) {
  return request({
    url: "/mes/sale/shipment/list",
    method: "get",
    params: query,
  });
}

// 打印发货单
export function printDelivery(ids) {
  return request({
    url: "/mes/sale/shipmentPrint/shipment/" + ids,
    method: "get",
  });
}

// 打印物流单
export function printLogistics(ids) {
  return request({
    url: "/mes/sale/shipmentPrint/eBill/" + ids,
    method: "get",
  });
}

// 更新收货地址/物流地址
export function updateLogisticsInfo(data) {
  return request({
    url: "/mes/sale/shipmentPrint/updateExpressConsignee",
    method: "put",
    data: data,
  });
}

// 批量修改打印状态
export function confirmLogisticsPrinted(data) {
  return request({
    url: "/mes/sale/shipmentPrint/updatePrintTag",
    method: "put",
    data: data,
  });
}

// 批量修改物流公司 todo

// 获取多包裹
export function getMultiPackage(data) {
  return request({
    url:
      "/mes/sale/shipmentPrint/getMultiPackage/" + data.id + "/" + data.count,
    method: "put",
  });
}

// 更新多包裹
export function updateMultiPackage(data) {
  return request({
    url:
      "/mes/sale/shipmentPrint/updateMultiPackage/" +
      data.id +
      "/" +
      data.count,
    method: "put",
  });
}

// 取消多包裹
export function cancelMultiPackage(ids) {
  return request({
    url: "/mes/sale/shipmentPrint/cancelMultiPackage/" + ids,
    method: "put",
  });
}

// 作废发货单
export function cancelDelivery(data) {
  return request({
    url: "/mes/sale/shipmentPrint/cancel",
    method: "put",
    data: data,
  });
}

// 填充物流单号
export function fillLogisticsCode(data) {
  return request({
    url: "/mes/sale/shipmentPrint/setExpressNo",
    method: "put",
    data: data,
  });
}

// 查销售订单明细 /ktg-mes/mes/sale/shipment/listOrder/{id}
export function getOrderItems(prepareId) {
  return request({
    url: "/mes/sale/shipment/listOrder/" + prepareId,
    method: "get",
  });
}

// 查商品明细 /ktg-mes/mes/sale/shipment/listProduct/{id}
export function getProductItems(prepareId) {
  return request({
    url: "/mes/sale/shipment/listProduct/" + prepareId,
    method: "get",
  });
}

// 查收货信息 /ktg-mes/mes/sale/shipment/deliveryInfo/{id}
export function getConsigneeInfo(prepareId) {
  return request({
    url: "/mes/sale/shipment/deliveryInfo/" + prepareId,
    method: "get",
  });
}

// 查包裹物流信息 T ​/ktg-mes​/mes​/sale​/shipment​/packageInfo​/{id}
export function getPackageLogisticsInfo(prepareId) {
  return request({
    url: "/mes/sale/shipment/packageInfo/" + prepareId,
    method: "get",
  });
}

// 导出发货单数据 todo
// export function exportDeliveryData(data) {
//   return request({
//     url: "/mes/sale/print/export/delivery",
//     method: "post",
//     data: data,
//     responseType: "blob",
//   });
// }

// 导出包裹数据 todo
// export function exportPackageData(data) {
//   return request({
//     url: "/mes/sale/print/export/package",
//     method: "post",
//     data: data,
//     responseType: "blob",
//   });
// }

// 销售发货
export function saleShip(ids) {
  return request({
    url: "/mes/sale/shipment/ship/" + ids,
    method: "put",
  });
}

// 销售强制发货
export function forceSaleShip(ids) {
  return request({
    url: "/mes/sale/shipment/forceShipment/" + ids,
    method: "put",
  });
}
